read also https://code.visualstudio.com/docs/editor/portable
Portable mode is only supported on the Windows ZIP archive of vscode
In [ ]:
!echo %winpydirbase%
go to https://code.visualstudio.com/Download
download a VSCode "zip" version for Windows
unzip it and rename the top directory as "VScode" (from, for example, "VSCode-win32-ia32-1.38.0")
place it under Winpython base directory %winpydirbase%\t\
you must have the code.exe executable in %winpydirbase%\t\VSCode\code.exe
create the directory %winpydirbase%\t\VSCode\data : seeing it VScode will put all is parametrizing there.
create the directory %winpydirbase%\t\VSCode\data\user-data\user\settings.json as follow:
{
"python.pythonPath": "${env:WINPYDIR}\\\\python.exe",
}
nota: the "VS Code" icon of WinPython should work with a fixed-PC installed VScode, by changing the setting of python.pythonPath as indicated above
In [ ]:
import os
os.environ["tmpjson"] = os.environ["winpydirbase"]+"\\t\\VSCode\\data\\user-data\\user\\settings.json"
!rem set tmpjson=%winpydirbase%\t\VSCode\data\user-data\user\settings.json
!if not exist "%winpydirbase%\t\vscode" mkdir "%winpydirbase%\t\vscode"
!if not exist "%winpydirbase%\t\vscode\data" mkdir "%winpydirbase%\t\vscode\data"
!if not exist "%winpydirbase%\t\vscode\data\user-data" mkdir "%winpydirbase%\t\vscode\data\user-data"
!if not exist "%winpydirbase%\t\vscode\data\user-data\user" mkdir "%winpydirbase%\t\vscode\data\user-data\user"
!if exist "%tmpjson%.txt" del "%tmpjson%.txt"
!if not exist %tmpjson% echo { > "%tmpjson%.txt"
!if not exist %tmpjson% echo "python.pythonPath": "${env:WINPYDIR}\\\\python.exe", >> "%tmpjson%.txt"
!if not exist %tmpjson% echo } >> "%tmpjson%.txt"
!if not exist "%tmpjson%" copy "%tmpjson%.txt" "%tmpjson%"
!if exist "%tmpjson%.txt" del "%tmpjson%.txt"
In [ ]:
!type "%tmpjson%"
nota: it will launch the %winpydirbase%\scripts\winvscode.bat:
DOS
@echo off
rem launcher for VScode
call "%~dp0env_for_icons.bat"
cd/D "%WINPYWORKDIR%"
if exist "%WINPYDIR%\..\t\vscode\code.exe" (
"%WINPYDIR%\..\t\vscode\code.exe" %*
) else (
"code.exe" %*
)
In [ ]:
#launching for you
!%winpydirbase%\scripts\winvscode.bat
Opening a first Python file will launch the Python extension
After about 20 seconds, Your WinPython Python Interpreter must appear on bottom left of the vscode window, as a proof it is recognized
.. if not, the Python extension will propose you to select it manually.
Open via "File->Open" of VScode a python file, like for example %winpydirbase\notebook\minesweeper.py
"Right-Click" in the middle of the source file and choose "Run Python File in Terminal"
see https://code.visualstudio.com/docs/python/jupyter-support
on the File Explorer of VS Code, right click on "baresql experiment.ipynb" and choose "Import Jupyter Notebook"
(yes, it does an import with some transformation)
"Right Click" on the source file obtained and choose "Run all cells" or click on individual "Run cell" that are displayed in the imported source.
beware Jupyter is very slow to start (twice slower than in direct mode ?)
go to vscode men "Files --> Preferences -> Settings
look for python.pythonPath and press enter
to get an automatically movable path, type in it
${env:WINPYDIR}\\python.exe
press enter to validate
The Selected Python Interpreter must appear on bottom left of the vscode window, as a proof it is recognized
In [ ]: